﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Edit.ascx.cs" Inherits="ZkSurvey.Web.VP.SurveyMgr.Edit" %>
<tbwc:StyleSheetControl ID="SscList" runat="server" CssPath="list.css">
</tbwc:StyleSheetControl>
<tbwc:StyleSheetControl ID="SscLink" runat="server" CssPath="VP/SurveyMgr/Edit.css">
</tbwc:StyleSheetControl>
<tbwc:StyleSheetControl ID="SscDatePickerdd" runat="server" CssPath="DatePicker/datepicker.css">
</tbwc:StyleSheetControl>
<tbwc:StyleSheetControl ID="SscModal" runat="server" CssPath="modaldialogs.css">
</tbwc:StyleSheetControl>
<ajaxToolKit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" CombineScripts="false"
    ID="ScriptManager1">
    <Scripts>
        <asp:ScriptReference Path="~/js/jquery-1.4.2.js" />
    </Scripts>
</ajaxToolKit:ToolkitScriptManager>
<script type="text/javascript">

    function reload() {
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
    }
    function EndRequestHandler() {
        $("select[id*=ddlQuesionType]").change(function () {

            if ($(this).val() == 3) {
                $("#DivAllowUserInput").hide();
            }
            else {
                $("#DivAllowUserInput").show();
            }
        });
    }
    //为了在每次UpdatePanel更新之后重新执行一次
    $(document).ready(function () { reload(); })
    $(document).ready(function () {
        $("select[id*=ddlQuesionType]").change(function () {

            if ($(this).val() == 3) {
                $("#DivAllowUserInput").hide();
            }
            else {
                $("#DivAllowUserInput").show();
            }
        });
    }); 
</script>
<table style="height: 100%; width: 100%;">
    <tr>
        <td id="leftPane">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <fieldset>
                        <div>
                            <asp:Label ID="LblSurveyTitle" runat="server" AssociatedControlID="tbxSurveyTitle"
                                Text="问卷标题:" CssClass="add"></asp:Label><asp:RequiredFieldValidator ID="rfvSurveyTitle"
                                    runat="server" ErrorMessage="(必填)" Display="Dynamic" ControlToValidate="tbxSurveyTitle"
                                    ValidationGroup="EditSurvey"></asp:RequiredFieldValidator>
                            <br />
                            <asp:TextBox ID="tbxSurveyTitle" runat="server" Width="25em" MaxLength="200"></asp:TextBox></div>
                        <div>
                            <asp:Label ID="LblSurveyDescription" runat="server" AssociatedControlID="tbxSurveyDescription"
                                Text="问卷说明:" CssClass="add"></asp:Label>
                            <asp:RequiredFieldValidator ID="RfvTitleVer" runat="server" ErrorMessage="(必填)" Display="Dynamic"
                                ControlToValidate="tbxSurveyDescription" ValidationGroup="EditSurvey"></asp:RequiredFieldValidator>
                            <br />
                            <asp:TextBox ID="tbxSurveyDescription" runat="server" Width="25em" TextMode="MultiLine"
                                Rows="10" MaxLength="200"></asp:TextBox></div>
                        <div>
                            <asp:Label ID="LblSurveyStartTime" runat="server" AssociatedControlID="tbxSurveyStartTime"
                                Text="开始时间:" CssClass="add"></asp:Label><asp:RequiredFieldValidator ID="RequiredFieldValidator2"
                                    runat="server" ErrorMessage="(必填)" Display="Dynamic" ControlToValidate="tbxSurveyStartTime"
                                    ValidationGroup="EditSurvey"></asp:RequiredFieldValidator>
                            <br />
                            <tbwc:DatePicker ID="tbxSurveyStartTime" Width="10em" runat="server" Value="" EnableTheming="true" />
                        </div>
                        <div>
                            <asp:Label ID="LblEndTime" runat="server" AssociatedControlID="tbxSurveyEndTime"
                                Text="结束时间:" CssClass="add"></asp:Label>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="(必填)"
                                Display="Dynamic" ControlToValidate="tbxSurveyEndTime" ValidationGroup="EditSurvey"></asp:RequiredFieldValidator>
                            <br />
                            <tbwc:DatePicker ID="tbxSurveyEndTime" Width="10em" runat="server" Value="" EnableTheming="true" />
                        </div>
                        <div>
                            <asp:Label ID="LblSurveyValidationCode" runat="server" AssociatedControlID="tbxSurveyValidationCode"
                                Text="验证码:" CssClass="add"></asp:Label><asp:Label ID="tbxSurveyValidationCode" runat="server"
                                    Text=""></asp:Label>
                        </div>
                        <div>
                            <asp:Label ID="LblSurveyCreator" runat="server" AssociatedControlID="tbxSurveyCreator"
                                Text="创建人:" CssClass="add"></asp:Label>
                            <asp:Label ID="tbxSurveyCreator" runat="server" Text=""></asp:Label>
                        </div>
                        <div>
                            <asp:Label ID="LblSurveyCreatTime" runat="server" AssociatedControlID="tbxSurveyCreatTime"
                                Text="创建时间:" CssClass="add"></asp:Label>
                            <asp:Label ID="tbxSurveyCreatTime" runat="server" Text=""></asp:Label>
                        </div>
                        <div>
                            <asp:Label ID="LblUrl" runat="server" AssociatedControlID="HlSurveyUrl" Text="问卷地址:"
                                CssClass="add"></asp:Label>
                            <asp:HyperLink ID="HlSurveyUrl" runat="server" Target="_blank"> </asp:HyperLink>
                        </div>
                        <div>
                            <asp:Label ID="Label11" runat="server" AssociatedControlID="tbxStatus" Text="问卷状态:"
                                CssClass="add"></asp:Label>
                            <asp:Label ID="tbxStatus" runat="server"> </asp:Label>
                        </div>
                        <div style="white-space: nowrap; text-align: center; margin-top: 2em;">
                            <asp:Button ID="BtnSaveEditSurvey" runat="server" Text="保存修改" ValidationGroup="EditSurvey"
                                OnClick="BtnSaveEditSurvey_Click" />&nbsp;
                            <asp:HyperLink ID="HlPreview" runat="server" Target="_blank" Text="预览问卷"></asp:HyperLink>
                        </div>
                    </fieldset>
                </ContentTemplate>
                <Triggers>
                </Triggers>
            </asp:UpdatePanel>
        </td>
        <td id="SplitTd">
        </td>
        <td id="rightPane">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <div id="relatedoperation">
                        <div style="float: right;">
                            <asp:LinkButton ID="LBtnNewQuestion" runat="server" CssClass="op">添加问题</asp:LinkButton>
                            <%--<asp:LinkButton ID="LBtnSearch" runat="server" CssClass="op">搜索</asp:LinkButton>--%>
                        </div>
                       <label style=" color:Red;"> [提示]&nbsp;对于运行中或者已结束的问卷调查不能修改问题及其选项</label>
                    </div>
                    <ajaxToolKit:ModalPopupExtender ID="MpeNewQuestion" runat="server" TargetControlID="LBtnNewQuestion"
                        PopupControlID="PnlNewQuestion" CancelControlID="BtnCancelNewQuestion" BackgroundCssClass="modalBackground"
                        PopupDragHandleControlID="PnlNewQuestionCaption" Drag="false">
                    </ajaxToolKit:ModalPopupExtender>
                    <asp:Panel ID="PnlNewQuestion" runat="server" CssClass="modalBox" Style="display: none;"
                        Width="500px">
                        <asp:Panel ID="PnlNewQuestionCaption" runat="server" CssClass="caption" Style="margin-bottom: 10px;
                            cursor: hand;">
                            添加问题
                        </asp:Panel>
                        <fieldset>
                            <div>
                                <asp:Label ID="Label3" runat="server" AssociatedControlID="tbxQuestionSort" Text="问题序号:"
                                    CssClass="add"></asp:Label><asp:TextBox ID="tbxQuestionSort" Width="12em" runat="server"
                                        MaxLength="200"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvQuestionSort" runat="server" ControlToValidate="tbxQuestionSort"
                                    ValidationGroup="NewQuestion" Display="Dynamic" ErrorMessage="(必填)"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" Display="Dynamic"
                                    ValidationExpression="^[1-9]\d*$" ControlToValidate="tbxQuestionSort" ErrorMessage="(仅限数字)"
                                    ValidationGroup="NewQuestion" runat="server"></asp:RegularExpressionValidator>
                            </div>
                            <div>
                                <asp:Label ID="Label2" runat="server" AssociatedControlID="ddlQuesionType" Text="问题类型:"
                                    CssClass="add"></asp:Label><asp:DropDownList ID="ddlQuesionType" Width="12em" runat="server">
                                    </asp:DropDownList>
                            </div>
                            <div id="DivAllowUserInput">
                                <asp:Label ID="Label4" runat="server" AssociatedControlID="cbxAllowInput" Text="允许输入:"
                                    CssClass="add"></asp:Label><asp:CheckBox ID="cbxAllowInput" runat="server" Checked="false" />
                            </div>
                            <div>
                                <asp:Label ID="Label1" runat="server" AssociatedControlID="tbxQuestionTitle" Text="题目:"
                                    CssClass="add"></asp:Label><asp:TextBox ID="tbxQuestionTitle" runat="server" Width="25em"
                                        MaxLength="200" TextMode="MultiLine" Rows="5"></asp:TextBox><asp:RequiredFieldValidator
                                            ID="RequiredFieldValidator4" runat="server" ErrorMessage="(必填)" Display="Dynamic"
                                            ControlToValidate="tbxQuestionTitle" ValidationGroup="NewQuestion"></asp:RequiredFieldValidator></div>
                            <div style="white-space: nowrap; text-align: center; margin-top: 2em;">
                                <asp:Button ID="BtnSaveNewQuestion" runat="server" Text="添加" ValidationGroup="NewQuestion"
                                    OnClick="BtnSaveNewQuestion_Click" />
                                <asp:Button ID="BtnCancelNewQuestion" runat="server" Text="取消" />
                            </div>
                        </fieldset>
                    </asp:Panel>
                    <div class="dataListArea">
                        <tbwc:GridViewEx ID="GvList" runat="server" SkinID="List" AllowPaging="true" PageSize="20"
                            OnRowCommand="GvList_RowCommand" OnRowDataBound="GvList_RowDataBound" OnPageIndexChanging="GvList_PageIndexChanging">
                            <EmptyDataTemplate>
                                还没有问题（这个设置没有起作用？）
                            </EmptyDataTemplate>
                            <Columns>
                                <asp:TemplateField HeaderText="序号">
                                    <ItemTemplate>
                                        <%#Eval("Sort") %>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="sort" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="题目">
                                    <ItemTemplate>
                                        <%#Eval("Title") %></ItemTemplate>
                                    <ItemStyle CssClass="title" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="问题类型">
                                    <ItemTemplate>
                                        <%#Eval("TypeTitle") %>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="type" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="问题选项">
                                    <ItemTemplate>
                                        <asp:Repeater ID="rptOptions" runat="server">
                                            <HeaderTemplate>
                                                <ul>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <li><span style="color: Red; font-weight: bold;">
                                                    <%#Eval("Value") %></span>.&nbsp;&nbsp;&nbsp;<%#Eval("Name") %></li>
                                            </ItemTemplate>
                                            <FooterTemplate>
                                                </ul>
                                            </FooterTemplate>
                                        </asp:Repeater>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="options" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LBtnEdit" runat="server" Text="编辑" CommandName="EditQues" CommandArgument='<%#Eval("Id") %>'
                                            CausesValidation="false"></asp:LinkButton>
                                        <asp:LinkButton ID="LBtnDelete" runat="server" Text="删除" OnClientClick='return confirm("确定要删除这个问题吗？");'
                                            CommandName="DeleteQues" CommandArgument='<%#Eval("Id") %>' CausesValidation="false"></asp:LinkButton>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ListOp" />
                                </asp:TemplateField>
                            </Columns>
                        </tbwc:GridViewEx>
                    </div>
                    <asp:HiddenField ID="BtnShowEditQuestion" runat="server" />
                    <ajaxToolKit:ModalPopupExtender ID="mpeEditQues" runat="server" TargetControlID="BtnShowEditQuestion"
                        PopupControlID="PnlEditQuestion" CancelControlID="BtnCancelEditQuestion" BackgroundCssClass="modalBackground"
                        PopupDragHandleControlID="PnlEditQuestionCaption" Drag="false">
                    </ajaxToolKit:ModalPopupExtender>
                    <asp:Panel ID="PnlEditQuestion" runat="server" CssClass="modalBox" Style="display: none;"
                        Width="500px">
                        <asp:Panel ID="PnlEditQuestionCaption" runat="server" CssClass="caption" Style="margin-bottom: 10px;
                            cursor: hand;">
                            编辑问题
                        </asp:Panel>
                        <div class="dataListArea">
                            <fieldset>
                                <div>
                                    <asp:Label ID="Label5" runat="server" AssociatedControlID="tbxEditQuesSort" Text="问题序号:"
                                        CssClass="add"></asp:Label><asp:TextBox ID="tbxEditQuesSort" Width="12em" runat="server"
                                            MaxLength="200"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="tbxEditQuesSort"
                                        ValidationGroup="EditQuestion" Display="Dynamic" ErrorMessage="(必填)"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" Display="Dynamic"
                                        ValidationExpression="^[1-9]\d*$" ControlToValidate="tbxEditQuesSort" ErrorMessage="(仅限数字)"
                                        ValidationGroup="EditQuestion" runat="server"></asp:RegularExpressionValidator>
                                </div>
                                <div>
                                    <asp:Label ID="Label6" runat="server" AssociatedControlID="lblEditQuesType" Text="问题类型:"
                                        CssClass="add"></asp:Label>
                                    <asp:Label ID="lblEditQuesType" runat="server"></asp:Label>
                                </div>
                                <div id="divEditQuesAllowInput" runat="server">
                                    <asp:Label ID="Label12" runat="server" AssociatedControlID="cbxEditQuesAllowInput"
                                        Text="允许输入:" CssClass="add"></asp:Label><asp:CheckBox ID="cbxEditQuesAllowInput"
                                            runat="server" Checked="false" />
                                </div>
                                <div>
                                    <asp:Label ID="Label7" runat="server" AssociatedControlID="tbxEditQuesTitle" Text="题目:"
                                        CssClass="add"></asp:Label><asp:TextBox ID="tbxEditQuesTitle" runat="server" Width="25em"
                                            MaxLength="200" TextMode="MultiLine" Rows="5"></asp:TextBox><asp:RequiredFieldValidator
                                                ID="RequiredFieldValidator5" runat="server" ErrorMessage="(必填)" Display="Dynamic"
                                                ControlToValidate="tbxEditQuesTitle" ValidationGroup="EditQuestion"></asp:RequiredFieldValidator></div>
                            </fieldset>
                            <div id="divEditOptions" runat="server">
                                <hr />
                                <div id="Div1">
                                    <div style="float: right;">
                                        <asp:LinkButton ID="LbtnNewOption" runat="server" CssClass="op" OnClick="LbtnNewOption_Click">添加选项</asp:LinkButton>
                                    </div>
                                    问题选项：
                                </div>
                                <tbwc:GridViewEx ID="gvOption" runat="server" SkinID="List" DataKeyNames="Id" AllowPaging="false"
                                    OnRowCommand="gvOption_RowCommand">
                                    <EmptyDataTemplate>
                                        还没有问题（这个设置没有起作用？）
                                    </EmptyDataTemplate>
                                    <Columns>
                                        <%--<asp:TemplateField HeaderText="No.">
                                        <ItemTemplate>
                                            <asp:Literal ID="LtrNo" runat="server"></asp:Literal></ItemTemplate>
                                        <ItemStyle CssClass="listNo" />
                                    </asp:TemplateField>--%>
                                        <asp:TemplateField HeaderText="序号">
                                            <ItemTemplate>
                                                <asp:TextBox ID="tbxOptSort" Width="35px" runat="server" Text=' <%#Eval("Sort") %>'></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvOptSort" runat="server" ControlToValidate="tbxOptSort"
                                                    ErrorMessage="*" ValidationGroup="EditQuestion" Display="Dynamic"> </asp:RequiredFieldValidator>
                                                <asp:RegularExpressionValidator ID="RevTeir" Display="Dynamic" ValidationExpression="^[1-9]\d*$"
                                                    ControlToValidate="tbxOptSort" ErrorMessage="(数字)" ValidationGroup="EditQuestion"
                                                    runat="server"></asp:RegularExpressionValidator>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="sort" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="标签">
                                            <ItemTemplate>
                                                <asp:TextBox ID="tbxOptValue" Width="35px" runat="server" Text=' <%#Eval("Value") %>'></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvOptValue" runat="server" ControlToValidate="tbxOptValue"
                                                    ErrorMessage="*" ValidationGroup="EditQuestion" Display="Dynamic"> </asp:RequiredFieldValidator>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="optValue" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="名称">
                                            <ItemTemplate>
                                                <asp:TextBox ID="tbxOptTitle" Width="94%" runat="server" Text=' <%#Eval("Name") %>'></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="rfvOptTitle" runat="server" ControlToValidate="tbxOptTitle"
                                                    ErrorMessage="*" ValidationGroup="EditQuestion" Display="Dynamic"> </asp:RequiredFieldValidator>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="optTitle" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="LBtnDelete" runat="server" Text="删除" CommandName="DeleteOpt"
                                                    OnClientClick="return confirm('确定要删除这个选项吗？');" CommandArgument='<%#Eval("Id") %>'
                                                    CausesValidation="false"></asp:LinkButton>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="OptListOp" />
                                        </asp:TemplateField>
                                    </Columns>
                                </tbwc:GridViewEx>
                            </div>
                        </div>
                        <div style="white-space: nowrap; text-align: center; margin-top: 2em;">
                            <asp:Button ID="BtnSaveEditQues" runat="server" Text="保存" ValidationGroup="EditQuestion"
                                OnClick="BtnSaveEditQues_Click" />
                            <asp:Button ID="BtnCancelEditQuestion" runat="server" Text="取消" />
                        </div>
                    </asp:Panel>
                    <asp:HiddenField ID="BtnNewOption" runat="server" />
                    <ajaxToolKit:ModalPopupExtender ID="mpeNewOption" runat="server" TargetControlID="BtnNewOption"
                        PopupControlID="PnlNewOption" BackgroundCssClass="modalBackground" PopupDragHandleControlID="PnlNewOptionCaption"
                        Drag="false">
                    </ajaxToolKit:ModalPopupExtender>
                    <asp:Panel ID="pnlNewOption" CssClass="modalBox" Style="display: none;" runat="server">
                        <asp:Panel ID="PnlNewOptionCaption" runat="server" CssClass="caption" Style="margin-bottom: 10px;
                            cursor: hand;">
                            添加选项
                        </asp:Panel>
                        <fieldset>
                            <div>
                                <asp:Label ID="Label8" runat="server" AssociatedControlID="tbxNewOptSort" Text="序号:"
                                    CssClass="add"></asp:Label><asp:TextBox ID="tbxNewOptSort" Width="12em" runat="server"
                                        MaxLength="200"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="tbxNewOptSort"
                                    ValidationGroup="NewOpt" Display="Dynamic" ErrorMessage="(必填)"></asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RevTeir" Display="Dynamic" ValidationExpression="^[1-9]\d*$"
                                    ControlToValidate="tbxNewOptSort" ErrorMessage="(仅限数字)" ValidationGroup="NewOpt"
                                    runat="server"></asp:RegularExpressionValidator>
                            </div>
                            <div>
                                <asp:Label ID="Label9" runat="server" AssociatedControlID="tbxNewOptValue" Text="标签:"
                                    CssClass="add"></asp:Label><asp:TextBox ID="tbxNewOptValue" Width="12em" runat="server"></asp:TextBox>(如:A)
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="tbxNewOptValue"
                                    ValidationGroup="NewOpt" Display="Dynamic" ErrorMessage="(必填)"></asp:RequiredFieldValidator>
                            </div>
                            <div>
                                <asp:Label ID="Label10" runat="server" AssociatedControlID="tbxNewOptName" Text="名称:"
                                    CssClass="add"></asp:Label><asp:TextBox ID="tbxNewOptName" runat="server" Width="25em"
                                        MaxLength="200"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator7"
                                            runat="server" ErrorMessage="(必填)" Display="Dynamic" ControlToValidate="tbxNewOptName"
                                            ValidationGroup="NewOpt"></asp:RequiredFieldValidator></div>
                        </fieldset>
                        <div style="white-space: nowrap; text-align: center; margin-top: 2em;">
                            <asp:Button ID="BtnSaveNewOpt" runat="server" Text="保存" ValidationGroup="NewOpt"
                                OnClick="BtnSaveNewOpt_Click" />
                            <asp:Button ID="BtnCancelNewOpt" CausesValidation="false" runat="server" Text="取消"
                                OnClick="BtnCancelNewOpt_Click" />
                        </div>
                    </asp:Panel>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="BtnSaveEditSurvey" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </td>
    </tr>
</table>
